<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>信审通过意见</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<form id="formSet1">
			<div class="fieldset1 tabel_col clearFix">
				<div class="caption">
					<span class="title">信审资料及承租人资质</span>
				</div>
				<div class="fieldBox col_100">
					<span>承租人</span>
				</div>
				<div class="fieldBox col_33">
					<div class="label">信审资料</div>
					<div class="field">
						<input name="creditInfo" id="creditInfo" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">资质情况</div>
					<div class="field">
						<input name="qualificationsInfo" id="qualificationsInfo" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">资产证明</div>
					<div class="field">
						<select name="assetsProveCd" id="assetsProveCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${assetsProveCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">融资次数</div>
					<div class="field">
						<input name="times" id="times" type="text" class="ui-textbox" value="" validate="{number:true}">
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">不良记录情况</div>
					<div class="field">
						<input name="badRecordInfo" id="badRecordInfo" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">法院执行情况</div>
					<div class="field">
						<input name="courtsEnforceInfo" id="courtsEnforceInfo" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<!-- 承租人资料动态页面  区分:自然人/法人 -->
				<div id="TenantDiv" class="fieldBox col_100_auto">
					<%-- <jsp:include page="audPassOpinionTenantDycPage.jsp"></jsp:include> --%>
				</div>
				
				<!-- ============================================================================= -->
				<div class="fieldBox col_100">
					<span>担保人</span>
				</div>
				<div id="GuarantorInfo" class="fieldBox col_100">
			        <div class="sqPanel">
			            <div class="sqPanel_body">
			                <div id="ligergrid_GuarantorInfo" class="sq-grid"></div>
			            </div>
			        </div>
			    </div>
			    <!-- <div class="fieldBox col_100">
					<span>法人担保人</span>
				</div>
				<div id="LegalGuarantor" class="fieldBox col_100">
			        <div class="sqPanel">
			            <div class="sqPanel_body">
			                <div id="ligergrid_LegalGuarantor" class="sq-grid"></div>
			            </div>
			        </div>
			    </div> -->
				<!-- ============================================================================= -->
				
				<div class="caption">
					<span class="title">产品政策</span>
				</div>
				<div class="fieldBox col_33">
					<div class="label">收益率</div>
					<div class="field">
						<input name="returnPct" id="returnPct" type="text" class="ui-textbox" data-tofix="2" validate="{number:true}">
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">执行政策标准</div>
					<div class="field">
						<select name="policyStandatrdsCd" id="policyStandatrdsCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${policyStandatrdsCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">是否符合标准</div>
					<div class="field">
						<select name="standardCd" id="standardCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${standardCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">执行模板</div>
					<div class="field">
						<select name="executeTemplateCd" id="executeTemplateCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${executeTemplateCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				
				<div class="caption">
					<span class="title">运营分析</span>
				</div>
				<div class="fieldBox col_100">
                    <div class="label">运营分析</div>
                    <div class="field" style="width: 100%;">
                        <textarea name="operationAnalysis" id="operationAnalysis" rows="4" class="l-textarea" style="width:99%" value="${previewoperationAnalysis }" >${previewoperationAnalysis }</textarea>
                    </div>
                </div>
                
				<div class="caption">
					<span class="title">信审员评价</span>
				</div>
				<div class="fieldBox col_100">
					<span>承租人</span>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">购车行为</div>
					<div class="field">
						<select name="buyCd" id="buyCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${buyCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">资产实力</div>
					<div class="field">
						<select name="lesseeAssetsCd" id="lesseeAssetsCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${lesseeAssetsCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">车辆配置</div>
					<div class="field">
						<select name="carConfigCd" id="carConfigCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${carConfigCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">融资方案</div>
					<div class="field">
						<select name="financePlanCd" id="financePlanCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${financePlanCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">运营情况</div>
					<div class="field">
						<select name="operationSituationCd" id="operationSituationCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${operationSituationCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">运营经验</div>
					<div class="field">
						<select name="operationExperienceCd" id="operationExperienceCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${operationExperienceCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
	            <div class="fieldBox col_33">
					<div class="label">第二还款来源</div>
					<div class="field">
						<select name="paymentSourceCd" id="paymentSourceCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${paymentSourceCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">经营状况</div>
					<div class="field">
						<input name="managementSituation" id="managementSituation" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				
				<!-- =========================================================================== -->
				<div class="fieldBox col_100">
					<span>担保人</span>
				</div>
				<div id="GuarantorEvaluate" class="fieldBox col_100">
			        <div class="sqPanel">
			            <div class="sqPanel_body">
			                <div id="ligergrid_GuarantorEvaluate" class="sq-grid"></div>
			            </div>
			        </div>
			    </div>
				<!-- =========================================================================== -->
				
				<div class="caption">
					<span class="title">风险</span>
				</div>
				<div class="fieldBox col_33">
					<div class="label">电话态度</div>
					<div class="field">
						<select name="attitudeCd" id="attitudeCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${attitudeCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">风险分析</div>
					<div class="field">
						<input name="riskAnalysis" id="riskAnalysis" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">可操作性评价</div>
					<div class="field">
						<select name="maneuverabilityCd" id="maneuverabilityCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${maneuverabilityCdList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">审批意见结束语</div>
					<div class="field">
						<input name="opinion" id="opinion" type="text" class="ui-textbox" value="" >
					</div>
				</div>
				
				<div id="car" class="caption" style="display: none">
					<span class="title">其他信息</span>
				</div>
				<div id="CarDiv" class="fieldBox col_100_auto" style="display: none">
					<jsp:include page="audPassOpinionCarDycPage.jsp"></jsp:include>
				</div>
				
				<div class="caption">
					<span class="title">备注</span>
				</div>
				<div class="fieldBox col_100">
                    <div class="label">备注</div>
                    <div class="field" style="width: 100%;">
                        <textarea name="otherInfo" id="otherInfo" rows="4" class="l-textarea" style="width:99%" value="" ></textarea>
                    </div>
                </div>
			</div>
			<div class="btnsBox">
				<span id="saveBtn1" class="sq-button sq-button-round" onclick="saveAudPassOpn();">保存</span> 
				<span id="previewBtn" class="sq-button sq-button-round" onclick="getPreviewString();">预览</span> 
				<input name="creditPassOpinionId" id="creditPassOpinionId" type="hidden" value="${id }">
			</div>
		</form>
	</div>

<script type="text/javascript">
var _projectId = '${projectId}';//项目ID
var _proIntId = '${proIntId}';//流程实例ID
var _tenantTypCd = '${tenantTypCd}';//承租人类型
var _prdTypCd = '${prdTypCd}';//产品类型

var mainData;//信审通过意见主数据

$(function(){
	$('#formSet1').ligerForm({
        validate : true
	});
	initData();
	SetIframe_height();
});

//预览
function getPreviewString(){
	var creditPassOpinionId = $("#creditPassOpinionId").val();
	if(StringUtils.isEmpty(creditPassOpinionId)){
		$.ligerDialog.SQalert({content: "请先保存信息!" , SQ_type: "warning" });
		return;
	}
	$.ligerDialog.SQopen({
        width: 900,
        height:500,
        title : '预览',
        url:'<%=path%>/audit/audPrjPassOp/toPreviewPage.do?projectId=${projectId}&proIntId=${proIntId}&id='+creditPassOpinionId,
        buttons: [
                {
	            text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no',
	            onclick: function (item, Dialog) {
	                if (Dialog.onCancel) Dialog.onCancel();
	            }
	        }
	    ]
    });
}

//刷新承租人资料模块
function refreshTenantDyncFild(){
	if(!_tenantTypCd || _tenantTypCd=='') return;
	var _bizTypCd = "CST0001";
	var _bizCd = _tenantTypCd;
	var _url_1 = '<%=path%>/audit/audPrjPassOp/toTenantDynamicFldPage.do';
	$("#TenantDiv").load(_url_1,{bizTypCd:_bizTypCd, bizCd:_bizCd},function(responseText,textStatus){
		$("#formSet1").check_ligerFormEditor();
		setTenantData();
	});
}
//刷新乘用车增加模块
function refreshCarDyncFild(){
	if(!_prdTypCd || _prdTypCd=='') return;
	var _bizTypCd = "PRD0001";
	var _bizCd = _prdTypCd.substring(0,3);
	var _url_1 = '<%=path%>/audit/audPrjPassOp/toCarDynamicFldPage.do';
	$("#CarDiv").load(_url_1,{bizTypCd:_bizTypCd, bizCd:_bizCd},function(responseText,textStatus){
		$("#formSet1").check_ligerFormEditor();
		if($("#quantities").length){
			$("#car").show();
			$("#CarDiv").show();
		}
		setCarData();
	});
}

//请求数据(参数:项目ID,流程实例ID)
function initData(){
	if(!_projectId || !_proIntId){
		return;
	}
   	var _url = '<%=path%>/audit/audPrjPassOp/getByProjectIdAndProIntId.do';
	$.ajax({
   		type: 'get',
   		dataType:'json',
   		data:{
   			projectId:_projectId,
   			proIntId:_proIntId
   		},
   		url: _url,
   		success:function(msg){
			if(msg.success == 1){
				setData(msg.data);//设置数据
   				mainData = msg.data;
			}else{
				$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			}
			refreshTenantDyncFild();
			refreshCarDyncFild();
			
			initGuarantorInfoList();//初始化信审资料担保人列表
			initGuarantorEvaluateList();//初始化信审员评价担保人列表
		}
	});
}

//设置页面数据
function setData(data){
	if(!data)return;
	var form = liger.get("formSet1");
	$("#creditPassOpinionId").val(data.id);//信审通过意见ID
	$("#creditInfo").val(data.creditInfo);
	$("#qualificationsInfo").val(data.qualificationsInfo);
	$("#times").val(data.times);
	$("#badRecordInfo").val(data.badRecordInfo);
	$("#courtsEnforceInfo").val(data.courtsEnforceInfo);
	$("#returnPct").val(data.returnPct);
	if(StringUtils.isNotEmpty(data.operationAnalysis)){
		$("#operationAnalysis").val(data.operationAnalysis);
	}
	$("#managementSituation").val(data.managementSituation);
	$("#riskAnalysis").val(data.riskAnalysis);
	$("#opinion").val(data.opinion);
	$("#otherInfo").val(data.otherInfo);
	form.setData({
		assetsProveCd:data.assetsProveCd,
		policyStandatrdsCd:data.policyStandatrdsCd,
		standardCd:data.standardCd,
		executeTemplateCd:data.executeTemplateCd,
		buyCd:data.buyCd,
		lesseeAssetsCd:data.lesseeAssetsCd,
		carConfigCd:data.carConfigCd,
		financePlanCd:data.financePlanCd,
		operationSituationCd:data.operationSituationCd,
		operationExperienceCd:data.operationExperienceCd,
		paymentSourceCd:data.paymentSourceCd,
		attitudeCd:data.attitudeCd,
		maneuverabilityCd:data.maneuverabilityCd,
	});
};
//设置承租人动态字段数据
function setTenantData(){
	if(!mainData) return;
	var form = liger.get("formSet1");
	$("#researchReport_tenant").val(mainData.researchReport);//自然人-调查报告显示
	$("#business_tenant").val(mainData.bizInfo);//法人-从事业务
	if(mainData.registerTm){	//法人-注册时间
   		var date = new Date(mainData.registerTm);
   		var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
   		$("#registerTm_tenant").val(dateStr);
   	}
};
//设置乘用车动态字段数据
function setCarData(){
	/* if(!mainData) return;
	var form = liger.get("formSet1");
	$("#quantities").val(mainData.quantities);
	$("#brandModel").val(mainData.brandModel);
	$("#marketPrice").val(mainData.marketPrice);
	$("#chinaLowestPrice").val(mainData.chinaLowestPrice);
	$("#provinceLowestPrice").val(mainData.provinceLowestPrice);
	$("#localLowestPrice").val(mainData.localLowestPrice);
	$("#systemPrice").val(mainData.systemPrice);
	if(mainData.registrationDt){
   		var date = new Date(mainData.registrationDt);
   		var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
   		$("#registrationDt").val(dateStr);
   	}
	$("#mileage").val(mainData.mileage);
	$("#display").val(mainData.display);
	$("#certificates").val(mainData.certificates);
	$("#incomeExpenditure").val(mainData.incomeExpenditure);
	$("#overdueInfo").val(mainData.overdueInfo);
	$("#liabilitiesInfo").val(mainData.liabilitiesInfo);
	$("#guarantInfo").val(mainData.guarantInfo);
	
	form.setData({
		isCarStandard:mainData.isCarStandard,
		assetsProveCd:mainData.assetsProveCd,
		isInquiry:mainData.isInquiry,
		isCreditStandard:mainData.isCreditStandard,
	}); */
};


function saveAudPassOpn(){
	var form = liger.get("formSet1");
    if (!form.valid()) {
    	$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
        return false;
    }
    var data = form.getData();
    data["GuarantorInfoJSON"] = JSON.stringify(GuarantorInfoGrid.getData());//担保人信审资料
    data["GuarantorEvaluateJSON"] = JSON.stringify(GuarantorEvaluateGrid.getData());//担保人信审员评价
    
    data["projectId"] = _projectId;//项目ID
    data["proIntId"] = _proIntId;//流程实例ID
    
    var id = $("#creditPassOpinionId").val();
    var url = '<%=path%>/audit/audPrjPassOp/add.do';
    if(id != ""){
    	url = '<%=path%>/audit/audPrjPassOp/modify.do';
    	data["id"]= id;
    }
   var wait_dialog;
    $.ajax({
		type: 'post',
		dataType:'json',
		data:data,
		url: url,
		beforeSend: function(){
	          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
	     },
		success:function(msg){
			 wait_dialog.close();
			 if(msg.success == 1){
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 if(msg.data){
					 $("#creditPassOpinionId").val(msg.data);
				 }
			 }else{
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			 }
		}
	});
}


//与承租人关系
var relationshipCdListJSON = [];
<c:if test="${not empty relationshipCdListJSON}"> relationshipCdListJSON = ${relationshipCdListJSON}; </c:if>
//资产证明
var assetsProveCdListJSON = [];
<c:if test="${not empty assetsProveCdListJSON}"> assetsProveCdListJSON = ${assetsProveCdListJSON}; </c:if>

//担保人通过意见-信审资料
var GuarantorInfoGrid;
function initGuarantorInfoList(){
	var opId = $("#creditPassOpinionId").val();
	
	GuarantorInfoGrid = $("#ligergrid_GuarantorInfo").ligerGrid({
        url: '<%=path%>/audit/audPrjPassOp/initGuarantorList.do',
        method: 'get',
        parms:{
        	prjId:_projectId,
        	opId:opId
        },
        columns: [
            {display: '担保人姓名',name:'guarNm', width: 150 },
            {display: '担保人类型',name:'guarTypCdNm', width: 80 },
            {display: '信审资料',name:'creditInfo', width: 150,editor: {type: 'text'} },
            {display: '资质情况',name:'qualificationsInfo', width: 150,editor: {type: 'text'} },
            {display: '资产证明',name:'assetsProveCd', width: 150,
            	editor: {
                    type: 'select',
                    data: assetsProveCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'assetsProveCd',
                textField: 'assetsProveCdNm',
                render: function (item) {
                    return item.assetsProveCdNm;
                }	
            },
            {display: '调查报告显示',name:'researchReport', width: 150,editor: {type: 'text'} },
            {display: '从事业务',name:'bizInfo', width: 150,editor: {type: 'text'} },
            {display: '与承租人关系', name: 'relationshipCd', width: 80,
                editor: {
                    type: 'select',
                    data: relationshipCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'relationshipCd',
                textField: 'relationshipCdNm',
                render: function (item) {
                    return item.relationshipCdNm;
                }
            },
            ],
        onBeforeSubmitEdit: function (e) {
        },
        onBeforeEdit: function (e) {
        	//法人禁用调查报告显示  自然人禁用从事业务
        	if (e.column.columnname == "researchReport" && e.record.guarTypCd==CustomerConstant.CST_TYPE_CORP_CD) {
            	e.column.editor.readonly=true;
            }else if (e.column.columnname == "bizInfo" && e.record.guarTypCd==CustomerConstant.CST_TYPE_NP_CD) {
            	e.column.editor.readonly=true;
            }else{
            	e.column.editor.readonly=false;
            }
        },
        onAfterShowData:function(){
        	SetIframe_height();
        },
        pageSize:100,
        usePagerOnLessPagesize: false,
        root: 'rows',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        height: 300,
        heightDiff: -2,
        enabledEdit: true,
        isScroll: false,
        checkbox: false,
        rownumbers: true,
        allowUnSelectRow: true,
        alternatingRow: false
    });
}
//资产实力
var lesseeAssetsCdListJSON = [];
<c:if test="${not empty lesseeAssetsCdListJSON}"> lesseeAssetsCdListJSON = ${lesseeAssetsCdListJSON}; </c:if>
//履行职责
var fulfilCdListJSON = [];
<c:if test="${not empty fulfilCdListJSON}"> fulfilCdListJSON = ${fulfilCdListJSON}; </c:if>

//担保人通过意见-信审员评价
var GuarantorEvaluateGrid;
function initGuarantorEvaluateList(){
	var opId = $("#creditPassOpinionId").val();
	
	GuarantorEvaluateGrid = $("#ligergrid_GuarantorEvaluate").ligerGrid({
        url: '<%=path%>/audit/audPrjPassOp/initGuarantorList.do',
        method: 'get',
        parms:{
        	prjId:_projectId,
        	opId:opId
        },
        columns: [
            {display: '担保人姓名',name:'guarNm', width: 150 },
            {display: '担保人类型',name:'guarTypCdNm', width: 100 },
            {display: '履行职责',name:'fulfilCd', width: 100,
            	editor: {
                    type: 'select',
                    data: fulfilCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'fulfilCd',
                textField: 'fulfilCdNm',
                render: function (item) {
                    return item.fulfilCdNm;
                }	
            },
            {display: '从事工作/主营业务',name:'bizDesc', width: 300,editor: {type: 'text'} },
            {display: '资产实力',name:'guarantorAssetsCd', width: 100,
            	editor: {
                    type: 'select',
                    data: lesseeAssetsCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'guarantorAssetsCd',
                textField: 'guarantorAssetsCdNm',
                render: function (item) {
                    return item.guarantorAssetsCdNm;
                }	
            },
            ],
        onBeforeSubmitEdit: function (e) {
        },
        onBeforeEdit: function (e) {
        	
        },
        onAfterShowData:function(){
        	SetIframe_height();
        },
        pageSize:100,
        usePagerOnLessPagesize: false,
        root: 'rows',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        height: 300,
        heightDiff: -2,
        enabledEdit: true,
        isScroll: false,
        checkbox: false,
        rownumbers: true,
        allowUnSelectRow: true,
        alternatingRow: false
    });
}


</script>
<div class="ClearLine"></div>
</body>
</html>
